﻿using LiveCharts.Wpf;
using Parylene_CVD.DataTransfer;
using Parylene_CVD.Model;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Parylene_CVD
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            GlobalVariables.InitGlobalVariables();
           
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (GlobalVariables.webSocketServer != null)
            {
                await GlobalVariables.webSocketServer.StartAsync();  // 启动服务器
            }
            
        }

        // 在窗口关闭时停止 WebSocket 服务器
        private async void Window_Closed(object sender, EventArgs e)
        {
            if (GlobalVariables.webSocketServer != null)
            {
                await GlobalVariables.webSocketServer.StopAsync();  // 停止服务器
            }
        }
    }
}